library(tidyverse)
library(sf)
## Warning: package 'sf' was built under R version 4.1.1
library(spData)
library(ggthemes)
library(ggspatial)
communities <- st_read("https://data.cityofchicago.org/api/geospatial/cauq-8yn6?method=export&format=KML")
## Reading layer `Layer #0' from data source
## `https://data.cityofchicago.org/api/geospatial/cauq-8yn6?method=export&format=KML'
## using driver `KML'
## Simple feature collection with 77 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -87.94011 ymin: 41.64454 xmax: -87.52414 ymax: 42.02304
## Geodetic CRS: WGS 84
EZ <- st_read("https://data.cityofchicago.org/api/geospatial/64xf-pyvh?method=export&format=KML")
## Reading layer `Layer #0' from data source
## `https://data.cityofchicago.org/api/geospatial/64xf-pyvh?method=export&format=KML'
## using driver `KML'
## Simple feature collection with 6 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -87.79058 ymin: 41.64456 xmax: -87.52446 ymax: 42.00532
## Geodetic CRS: WGS 84
bus_stops <- st_read("CTA_BusStops.kml")
## Reading layer `CTA_BusStops' from data source
## `C:\Users\Samantha\Desktop\vis2128_1\CTA_BusStops.kml' using driver `KML'
## Simple feature collection with 10833 features and 2 fields
## Geometry type: POINT
## Dimension: XYZ
## Bounding box: xmin: -87.8843 ymin: 41.64416 xmax: -87.5257 ymax: 42.0647
## z_range: zmin: 0 zmax: 0
## Geodetic CRS: WGS 84
bus_routes <- st_read("CTA_Routes.kml")
## Reading layer `CTA_Routes' from data source
## `C:\Users\Samantha\Desktop\vis2128_1\CTA_Routes.kml' using driver `KML'
## Simple feature collection with 127 features and 2 fields
## Geometry type: MULTILINESTRING
## Dimension: XYZ
## Bounding box: xmin: -87.88664 ymin: 41.64384 xmax: -87.52574 ymax: 42.06518
## z_range: zmin: 0 zmax: 0
## Geodetic CRS: WGS 84
communities_plot <- ggplot(communities) +
geom_sf()
communities_plot

EZ_plot <- ggplot(EZ) +
geom_sf()
EZ_plot

bus_stops_plot <- ggplot(bus_stops) +
geom_sf()
bus_stops_plot

bus_routes_plot <- ggplot(bus_routes) +
geom_sf()
bus_routes_plot

map_1_bw <- ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "stamenbw") +
geom_sf(data = communities, size = 0.5, alpha = 0.3, aes(fill = "Community Boundaries")) +
geom_sf(data = EZ, color = NA, aes(fill = "Enterprise Zones")) +
geom_sf(data = bus_routes, aes(color = "CTA Bus Routes")) +
geom_sf(data = bus_stops, shape = 20, size = 0.001, aes(color = "CTA Bus Stops")) +
scale_fill_manual(values = c("black", "gray27"), name = "") +
scale_color_manual(values = c("black", "black"), name = "") +
theme_void() +
labs(caption = "Map tiles by Stamen Design. Data by OpenStreetMap")
map_1_bw

map_2 <- ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "stamenbw") +
geom_sf(data = communities, color = "pink", size = 0.5, alpha = 0.3, aes(fill = "Community Boundaries")) +
geom_sf(data = EZ, color = "yellow", alpha = 0.3, aes(fill = "Enterprise Zones")) +
geom_sf(data = bus_routes, aes(color = "CTA Bus Routes")) +
geom_sf(data = bus_stops, shape = 3, size = 0.01, aes(color = "CTA Bus Stops")) +
scale_fill_manual(values = c("pink", "yellow"), name = "") +
scale_color_manual(values = c("red", "darkred"), name = "") +
theme_void() +
labs(caption = "Map tiles by Stamen Design. Data by OpenStreetMap")
map_2

map_3 <- ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "cartolight") +
geom_sf(data = communities, color = "pink", alpha = 0.3, aes(fill = "Community Boundaries")) +
geom_sf(data = EZ, color = NA, alpha = 0.3, aes(fill = "Enterprise Zones")) +
geom_sf(data = bus_routes, aes(color = "CTA Bus Routes")) +
geom_sf(data = bus_stops, shape = 3, size = 0.01, aes(color = "CTA Bus Stops")) +
scale_fill_manual(values = c("pink", "yellow"), name = "") +
scale_color_manual(values = c("red", "darkred"), name = "") +
theme_void() +
labs(caption = "Map tiles and data by OpenStreetMap")
map_3

map_4 <- ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "stamenbw") +
geom_sf(data = communities, color = NA, alpha = 0.3, aes(fill = "Community Boundaries")) +
geom_sf(data = EZ, color = NA, alpha = 0.3, aes(fill = "Enterprise Zones")) +
geom_sf(data = bus_routes, aes(color = "CTA Bus Routes")) +
geom_sf(data = bus_stops, shape = 20, size = 0.01, aes(color = "CTA Bus Stops")) +
scale_fill_manual(values = c("firebrick", "orange"), name = "") +
scale_color_manual(values = c("dodgerblue", "dodgerblue4"), name = "") +
theme_void() +
labs(caption = "Map tiles by Stamen Design. Data by OpenStreetMap")
map_4

map_5 <- ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "cartodark") +
geom_sf(data = communities, color = "lightsteelblue2", size = 0.3, alpha = 0.5, aes(fill = "Community Boundaries")) +
geom_sf(data = EZ, color = "lightpink3", alpha = 0.5, aes(fill = "Enterprise Zones")) +
geom_sf(data = bus_routes, aes(color = "CTA Bus Routes")) +
geom_sf(data = bus_stops, shape = 1, size = 0.01, aes(color = "CTA Bus Stops")) +
scale_fill_manual(values = c("lightsteelblue4", "lightpink3"), name = "") +
scale_color_manual(values = c("navy", "yellow"), name = "") +
theme_void() +
labs(caption = "Map tiles by Stamen Design. Data by OpenStreetMap")
map_5

map_6 <- ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "hikebike") +
geom_sf(data = communities, color = NA, alpha = 0.5, aes(fill = "Community Boundaries")) +
geom_sf(data = EZ, color = NA, alpha = 0.5, aes(fill = "Enterprise Zones")) +
geom_sf(data = bus_routes, aes(color = "CTA Bus Routes")) +
geom_sf(data = bus_stops, shape = 17, size = 2, aes(color = "CTA Bus Stops")) +
scale_fill_manual(values = c("firebrick", "orange"), name = "") +
scale_color_manual(values = c("dodgerblue", "dodgerblue4"), name = "") +
theme_void() +
labs(caption = "Map tiles and data by OpenStreetMap")
map_6
